﻿using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using Inaction.Criteria;
using Inaction.Mapping;
using Inaction.UI.Common;
using System;
using System.Linq;
using System.Windows.Forms;

namespace Inaction.UI.Settings
{
    public static class LookUpEditBaseSetting
    {
        public static void SetProperties(LookUpEditBase c)
        {
            #region 属性设置
            c.Properties.NullText = string.Empty;
            c.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;
            c.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
            c.Properties.ImmediatePopup = true;
            c.Properties.CloseUpKey = new DevExpress.Utils.KeyShortcut(Keys.Space);

            if (c is LookUpEdit)
            {
                var lue = c as LookUpEdit;
                lue.Properties.SearchMode = DevExpress.XtraEditors.Controls.SearchMode.OnlyInPopup;
                lue.Properties.SortColumnIndex = 0;
                lue.Properties.AutoSearchColumnIndex = 0;
            }
            if (c is TreeListLookUpEdit)
            {
                var treeLue = c as TreeListLookUpEdit;
                treeLue.Properties.TreeList.OptionsView.ShowAutoFilterRow = true;
            }
            if (c is GridLookUpEdit)
            {
                var glue = c as GridLookUpEdit;
                glue.Properties.View.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;
                glue.Properties.View.OptionsSelection.EnableAppearanceFocusedCell = false;
                glue.Properties.View.OptionsView.ShowAutoFilterRow = true;
                glue.Properties.View.OptionsView.ShowGroupPanel = false;
            }
            #endregion            
        }
    }
}